**=================================**
** Mettler,Zhu and Jacobs APSR2022 **
** Threat, Partisanship and ACA	   **
** Do File for Tables and Figures  **
** Last Update on May 23, 2022     **
**=================================**

clear
* Zhu directory
cd "/Users/lingzhu/Dropbox/JacobsMettlerZhu/APSR2022 Dataverse/"
use "3.MZJAPSR2022 Replication Data.dta"

xtset qkey_alt wave
**================================** 
*  Table 2, DV: Favorability	  **
**================================**
* Table 2-(1) Linear Baseline Model
xtreg favorability party7pt impcaccs income35k year2018 ///
polknowl education age female raceethc l.favorability, vce(robust)

* Table 2-(2) Including one interaction between party and year2018
xtreg favorability party7pt party_yr2018 year2018 impcaccs ///
polknowl education age female income35k raceethc l.favorability, vce(robust)

* Table 1-(3) Including two interactions impcaccsX Year2018 and party X Year2018
xtreg favorability party7pt party_yr2018 impcaccs access_yr2018 year2018 ///
income35k polknowl education age female raceethc ///
l.favorability, vce(robust)

* Table 1-(4) Including two interactions income X Year2018 and party X Year2018
xtreg favorability party7pt party_yr2018 year2018 impcaccs ///
income35k income_yr2018 polknowl education age female raceethc ///
l.favorability, vce(robust)

* Table 1-(5) Full model with three interaction terms
* Model reported in the manuscript, using "reg"
reg favorability year2018 party7pt party_yr2018 impcaccs access_yr2018 ///
income35k income_yr2018 polknowl  education ///
age female raceethc l.favorability, vce(robust)

* Robustnese check: Full model estimated using "xtreg"
xtreg favorability year2018 party7pt party_yr2018 impcaccs access_yr2018 ///
income35k income_yr2018 polknowl  education ///
age female raceethc l.favorability, vce(robust)


**================================** 
* Clarify Figures for Interactions**
* Based on Table 2- Model (5)	  **
**================================**

*---Figure 1 Partisanship----*
estsimp reg favorability year2018 party7pt party_yr2018 impcaccs access_yr2018 ///
income35k income_yr2018 polknowl education ///
age female raceethc l_favorability, vce(robust)

generate year2018_lower=.   
generate year2018_upper=.
generate year2018_mean=.

generate before2018_lower = .
generate before2018_upper = .
generate before2018_mean =.
generate vectaxis = .  

recast float vectaxis  	   
local a=1			
local b=1							 
while `a' <= 7{                            
setx year2018 1 party7pt `a' party_yr2018 `a'*1 access_yr2018 2.16 income_yr2018 0.325 ///
	 ( impcaccs income35k polknowl education age female raceethc l_favorability) mean ///
                          					   
simqi, ev genev(p1)       
	_pctile p1, p(2.5, 50, 97.5)      
	display `a'
	replace year2018_lower = r(r1) in `b'   
	replace year2018_mean = r(r2) in `b'  
	replace year2018_upper = r(r3) in `b'  
	  
setx year2018 0 party7pt `a' party_yr2018 0 access_yr2018 0  income_yr2018 0 ///
	 (impcaccs income35k polknowl education age female raceethc l_favorability) mean ///
						   
simqi, ev genev(p2)        
	_pctile p2, p(2.5, 50, 97.5)      
	display `a'
	replace before2018_lower = r(r1) in `b'   
	replace before2018_mean = r(r2) in `b'  
	replace before2018_upper = r(r3) in `b' 
		    
	replace vectaxis = `a' in `b'      
	drop p1
	drop p2
	local a = `a' + 1        
	local b=`b'+ 1          
}
*****

twoway (rcap year2018_lower year2018_upper vectaxis, lcolor(gs2)) /*
	   */ (scatter year2018_mean vectaxis, mcolor(gs2)) /*
	   */ (rcap before2018_low before2018_upper vectaxis, lcolor(gs8) lpattern(vshortdash)) /*
	   */ (scatter before2018_mean vectaxis, lpattern(solid) mcolor(gs8)), /*
	   */ ytitle(Predicted Favorability Score) /*
       */ ytitle(,size(medsmall)) ylabel(2(1)7,labsize(medsmall)) /*
       */ xtitle("Respondents' Partisan Identification", size(medsmall)) /*
       */ xlabel(1(1)7, labsize(medsmall))/*
       */ legend(on order(1 "95% CI, Year 2018" 2 "Mean Prediction, Year 2018" /*
       */ 3 "95% CI, Years before 2018" 4 "Mean Prediction, Years before 2018") size(vsmall) lcolor(black) ring(0) position(5)) /* 
       */ yline(0, lpattern(dot) lcolor(red)) /*
       */ scheme(lean1) xsize(10)  ysize(10) /*
       */ name(partisanship, replace)	  	   
graph export partisanship.pdf, replace

drop b1-b14
drop b15
drop year2018_lower year2018_mean year2018_upper before2018_lower before2018_mean before2018_upper vectaxis

*----Figure 2 Access----
estsimp reg favorability year2018 party7pt party_yr2018 impcaccs access_yr2018 ///
income35k income_yr2018 polknowl education ///
age female raceethc l_favorability, vce(robust)

generate year2018_lower=.   
generate year2018_upper=.
generate year2018_mean=.

generate before2018_lower = .
generate before2018_upper = .
generate before2018_mean =.
generate vectaxis = .  

recast float vectaxis  	   
local a=1			
local b=1							 
while `a' <= 5{                            
setx year2018 1  impcaccs `a' party_yr2018 4.2*1 access_yr2018 `a'*1  income_yr2018 0.325 ///
	 (party7pt income35k polknowl education age female raceethc l_favorability) mean ///
                          					   
simqi, ev genev(p1)       
	_pctile p1, p(2.5, 50, 97.5)      
	display `a'
	replace year2018_lower = r(r1) in `b'   
	replace year2018_mean = r(r2) in `b'  
	replace year2018_upper = r(r3) in `b'  
	  
setx year2018 0  impcaccs `a' party_yr2018 0 access_yr2018 0  income_yr2018 0 ///
	 (party7pt income35k polknowl education age female raceethc l_favorability) mean ///
						   
simqi, ev genev(p2)        
	_pctile p2, p(2.5, 50, 97.5)      
	display `a'
	replace before2018_lower = r(r1) in `b'   
	replace before2018_mean = r(r2) in `b'  
	replace before2018_upper = r(r3) in `b' 
		    
	replace vectaxis = `a' in `b'      
	drop p1
	drop p2
	local a = `a' + 1        
	local b=`b'+ 1          
}
*****
twoway (rcap year2018_lower year2018_upper vectaxis, lcolor(gs2)) /*
	   */ (scatter year2018_mean vectaxis, mcolor(gs2)) /*
	   */ (rcap before2018_low before2018_upper vectaxis, lcolor(gs8) lpattern(vshortdash)) /*
	   */ (scatter before2018_mean vectaxis, lpattern(solid) mcolor(gs8)), /*
	   */ ytitle(Predicted Favorability Score) /*
       */ ytitle(,size(medsmall)) ylabel(3(1)7,labsize(medsmall)) /*
       */ xtitle("ACA's Impact on Access to Insurance", size(medsmall)) /*
       */ xlabel(1(1)5, labsize(medsmall))/*
       */ legend(on order(1 "95% CI, Year 2018" 2 "Mean Prediction, Year 2018" /*
       */ 3 "95% CI, Years before 2018" 4 "Mean Prediction, Years before 2018") size(vsmall) lcolor(black) ring(0) position(2)) /* 
       */ yline(0, lpattern(dot) lcolor(red)) /*
       */ scheme(lean1) xsize(10)  ysize(10) /*
       */ name(Access, replace)	  	   
graph export Access.pdf, replace

drop b1-b14
drop b15
drop year2018_lower year2018_mean year2018_upper before2018_lower before2018_mean before2018_upper vectaxis


*----Figure 3 Income----
estsimp reg favorability year2018 party7pt party_yr2018 impcaccs access_yr2018 ///
income35k income_yr2018 polknowl education ///
age female raceethc l_favorability, vce(robust)

generate year2018_lower=.   
generate year2018_upper=.
generate year2018_mean=.

generate before2018_lower = .
generate before2018_upper = .
generate before2018_mean =.
generate vectaxis = .  

recast float vectaxis  	   
local a=0			
local b=1							 
while `a' <= 1{                            
setx year2018 1  income35k `a' party_yr2018 4.2*1 access_yr2018 2.16*1  income_yr2018 `a'*1 ///
	 (party7pt impcaccs polknowl education age female raceethc l_favorability) mean ///
                          					   
simqi, ev genev(p1)       
	_pctile p1, p(2.5, 50, 97.5)      
	display `a'
	replace year2018_lower = r(r1) in `b'   
	replace year2018_mean = r(r2) in `b'  
	replace year2018_upper = r(r3) in `b'  
	  
setx year2018 0  income35k `a' party_yr2018 0 access_yr2018 0  income_yr2018 0 ///
	 (party7pt impcaccs polknowl education age female raceethc l_favorability) mean ///
						   
simqi, ev genev(p2)        
	_pctile p2, p(2.5, 50, 97.5)      
	display `a'
	replace before2018_lower = r(r1) in `b'   
	replace before2018_mean = r(r2) in `b'  
	replace before2018_upper = r(r3) in `b' 
		    
	replace vectaxis = `a' in `b'      
	drop p1
	drop p2
	local a = `a' + 1        
	local b=`b'+ 1          
}
*****
twoway (rcap year2018_lower year2018_upper vectaxis, lcolor(gs2)) /*
	   */ (scatter year2018_mean vectaxis, mcolor(gs2)) /*
	   */ (rcap before2018_low before2018_upper vectaxis, lcolor(gs8) lpattern(vshortdash)) /*
	   */ (scatter before2018_mean vectaxis, lpattern(solid) mcolor(gs8)), /*
	   */ ytitle(Predicted Favorability Score) /*
       */ ytitle(,size(medsmall)) ylabel(3(1)7,labsize(medsmall)) /*
       */ xtitle("Income", size(medsmall)) /*
       */ xlabel(-1(1)2, labsize(medsmall))/*
       */ legend(on order(1 "95% CI, Year 2018" 2 "Mean Prediction, Year 2018" /*
       */ 3 "95% CI, Years before 2018" 4 "Mean Prediction, Years before 2018") size(vsmall) lcolor(black) ring(0) position(2)) /* 
       */ yline(0, lpattern(dot) lcolor(red)) /*
       */ scheme(lean1) xsize(10)  ysize(10) /*
       */ name(Income, replace)	  	   
graph export Income.pdf, replace

drop b1-b14
drop b15
drop year2018_lower year2018_mean year2018_upper before2018_lower before2018_mean before2018_upper


**================================** 
*  Table 3, DV: Health Care Issue **
*				Matters for Voting**
**================================**
xtset qkey_alt wave

* Table 3-Model (1), Baseline model without nteraction terms
reg votehlth2 year2018 party7pt impcaccs income35k polknowl ///
education age female raceethc l.votehlth2 , vce(robust)

* Table 3-Model (2), With three interaction terms
reg votehlth2 year2018 party7pt party_yr2018 impcaccs access_yr2018 ///
income35k income_yr2018 polknowl education age female raceethc ///
l.votehlth2, vce(robust)

**================================ ** 
* Clarify Figures for Interactions **
* Based on Table 2, Model (2)	   **
**================================ **
*---Figure 4 Partisanship----*
estsimp reg votehlth2 year2018 party7pt party_yr2018 impcaccs ///
access_yr2018 income35k income_yr2018 polknowl education age female ///
raceethc l_vote, vce(robust)
 
generate year2018_lower=.   
generate year2018_upper=.
generate year2018_mean=.

generate before2018_lower = .
generate before2018_upper = .
generate before2018_mean =.
generate vectaxis = .  

recast float vectaxis  	   
local a=1			
local b=1							 
while `a' <= 7{                            
setx year2018 1 party7pt `a' party_yr2018 `a'*1 access_yr2018 2.16 income_yr2018 0.325 ///
	 (impcaccs income35k polknowl education age female raceethc l_vote) mean ///
                          					   
simqi, ev genev(p1)       
	_pctile p1, p(2.5, 50, 97.5)      
	display `a'
	replace year2018_lower = r(r1) in `b'   
	replace year2018_mean = r(r2) in `b'  
	replace year2018_upper = r(r3) in `b'  
	  
setx year2018 0 party7pt `a' party_yr2018 0 access_yr2018 0 income_yr2018 0 ///
	 (impcaccs income35k polknowl education age female raceethc l_vote) mean ///
						   
simqi, ev genev(p2)        
	_pctile p2, p(2.5, 50, 97.5)      
	display `a'
	replace before2018_lower = r(r1) in `b'   
	replace before2018_mean = r(r2) in `b'  
	replace before2018_upper = r(r3) in `b' 
		    
	replace vectaxis = `a' in `b'      
	drop p1
	drop p2
	local a = `a' + 1        
	local b=`b'+ 1          
}
*****
twoway (rcap year2018_lower year2018_upper vectaxis, lcolor(gs2)) /*
	   */ (scatter year2018_mean vectaxis, mcolor(gs2)) /*
	   */ (rcap before2018_low before2018_upper vectaxis, lcolor(gs8) lpattern(vshortdash)) /*
	   */ (scatter before2018_mean vectaxis, lpattern(solid) mcolor(gs8)), /*
	   */ ytitle(Predicted Importance of Health Care to Vote) /*
       */ ytitle(,size(medsmall)) ylabel(2(0.5)4,labsize(medsmall)) /*
       */ xtitle("Respondents' Partisan Identification", size(medsmall)) /*
       */ xlabel(1(1)7, labsize(medsmall))/*
       */ legend(on order(1 "95% CI, Year 2018" 2 "Mean Prediction, Year 2018" /*
       */ 3 "95% CI, Years before 2018" 4 "Mean Prediction, Years before 2018") size(vsmall) lcolor(black) ring(0) position(5)) /* 
       */ yline(0, lpattern(dot) lcolor(red)) /*
       */ scheme(lean1) xsize(10)  ysize(10) /*
       */ name(partisanship_vote, replace)	  	   
graph export partisanship_vote.pdf, replace

drop b1-b14
drop b15
drop year2018_lower year2018_mean year2018_upper before2018_lower before2018_mean before2018_upper vectaxis

 
**================================** 
*  Footnotes and Appendix		  **
**================================**

* Footnote 10 Checking Results for the baseline model by Subsamples (Insurance Coverage)
* Government Insurance
xtreg favorability year2018 party7pt impcaccs income35k polknowl  education ///
age female raceethc l.favorability if govtinsured==1, vce(robust)

* Private Insurance
xtreg favorability year2018 party7pt impcaccs income35k polknowl  education ///
age female raceethc l.favorability if insured2==0, vce(robust)
 
* Subsample for the insured, with three interaction terms
xtreg favorability year2018 party7pt party_yr2018 impcaccs access_yr2018 income35k ///
income_yr2018 polknowl  education age female raceethc l.favorability if insured2==1, vce(robust)

* In the main text: Alternative Specificaitons including fixed effects
* Model with three interactions and year fixed effects
xi: xtreg favorability year2018 party7pt party_yr2018 impcaccs access_yr2018 income35k ///
income_yr2018 polknowl  education age female raceethc l.favorability i.year 

* Model with three interactions and fixed effects by respondents
areg favorability year2018 party7pt party_yr2018 impcaccs access_yr2018 income35k ///
income_yr2018 polknowl  education age female raceethc l.favorability, absorb(qkey_alt)


* Appendix Table 1. Tabulation of Democrats' Favorability Score By Year 
tab favorability if party7pt>4&year==2010
tab favorability if party7pt>4&year==2012
tab favorability if party7pt>4&year==2014
tab favorability if party7pt>4&year==2016
tab favorability if party7pt>4&year==2018

* Appendix Table 2. Results Using the Tobit Regression Specification
* Appendix Table 2-(1)
tobit favorability year2018 party7pt impcaccs income35k polknowl education ///
age female raceethc l.favorability

* Appendix Table 2-(2)
tobit favorability year2018 party7pt party_yr2018 impcaccs access_yr2018 ///
income35k income_yr2018 polknowl  education age female raceethc l.favorability
